package com.penghaisoft.microwms.product.web.controller.expose;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.penghaisoft.microwms.common.Constant;
import com.penghaisoft.microwms.common.controller.BaseController;
import com.penghaisoft.microwms.common.data.model.ProSellOut;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.dto.TransResult;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.IWmsCommonService;
import com.penghaisoft.microwms.product.service.IProSellOutService;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping(value = "/expose/prosellout")
@Slf4j
public class ProExposeSellOutController extends BaseController {

    @Autowired
    private IProSellOutService proSellOutService;
    
    @Autowired
	private IWmsCommonService wmsCommonService;   
    
    /**
     * @Description 成品销售出库单创建
     * @copy luoteng
     * @param list
     * @return TransResult
     */
    @PostMapping("insert")
    public TransResult proSellOutCreate(@RequestBody List<ProSellOut> list) {
        TransResult transResult = new TransResult();
        if(list == null || list.isEmpty()){
            transResult.setCode(Constant.FAIL);
            transResult.setMsg("请选择成品型号及数量！");
            return transResult;
        }else{
        	String sellOutNo = wmsCommonService.getProShortSeq5(Constant.SEQ_PREFIX_SHORT_XSC, Constant.SEQ_PREFIX_SHORT_REDIS_PRO_XSC, 1).get(0);
            Resp resp = proSellOutService.insert(list, sellOutNo, "");
            transResult.setCode(resp.getCode());
            transResult.setMsg(resp.getMsg());
        }

        return transResult;
    }
    
}
